<template>
  <div class="comp-publication-wrapper window-wrapper">
    <div class="container">
      <div class="pub-area">
        <div class="area-wrapper ">
          <h3><i class="el-icon-position"/> {{$store.state.language === 'zh-CN' ? '研究方向' : 'Research Direction'}}</h3>
          <div class="area-container" v-if="$store.state.language === 'zh-CN'">
            <div class="area-instance" v-for="item in areaList" :key="item.id">
              <div class="title">{{item.title}}</div>
              <div class="content">{{item.content}}</div>
            </div>
          </div>
          <div class="area-container" v-else>
            <div class="area-instance" v-for="item in enAreaList" :key="item.id">
              <div class="title">{{item.title}}</div>
              <div class="content">{{item.content}}</div>
            </div>
          </div>
        </div>
        <div class="pub-container">
          <h3 v-if="$store.state.language === 'zh-CN'">
            <i class="el-icon-notebook-2"/> 代表论文
            <span>限于篇幅，仅列出部分论文</span>
            <div class="read-more" @click="$router.push('/Papers')">更多</div>
          </h3>
          <h3 v-else>
            <i class="el-icon-notebook-2"/> Selected Papers
            <span>Due to space, only some papers are listed</span>
            <div class="read-more" @click="$router.push('/Papers')">More</div>
          </h3>
          <div class="pub-instance" v-for="(item,_) in pubList" :key="item.id">
            <span class="number">{{_ + 1}}.</span>
            <div class="content" v-html="item.content">
              {{item.content}}
            </div>
          </div>
        </div>
      </div>
      <!-- <div class="photos-container">
                <el-divider content-position="center">
                    {{ $store.state.language === 'zh-CN' ?  '团队风采' : 'Team Show'}}
                </el-divider>
                <div class="img-instance" v-for="item in 6" :key="item">
                    <img :src="require(`../assets/research-group-${item}.jpg`)"/>
                </div>
      </div>-->
    </div>
  </div>
</template>
<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
import { RequestStatus } from "../utils/constans";
import { formatBackTime } from "../utils/common";
import { iPublication, iResearchArea } from "../typings/publication";
import $api from "../api";
import mockArea from '../mock/researchDirection';
import mockPublication from '../mock/puplication';

@Component
export default class CompPublication extends Vue {
  private pubList: iPublication[] = [];

  private areaList: iResearchArea[] = [];
  private enAreaList: iResearchArea[] = [];

  mounted() {
    this.getPublicationList();
    this.getResearchAreaList();
  }

  getPublicationList() {
    const succ = (res: any) => {
      (res as any).map((record: iPublication) => {
        if (this.pubList.length < 10) {
          this.pubList.push(record);
        }
      });
    };
    if (this.$store.state.offModel) {
      succ(mockPublication);
    } else {
      $api.publication.findAllPublicationClient().then(succ);
    }
  }

  getResearchAreaList() {
    const succ = (res: any) => {
      (res as any).map((record: iResearchArea) => {
        if (record.language === "英语") {
          this.enAreaList.push(record);
        } else if (record.language !== "英语") {
          this.areaList.push(record);
        }
      });
    }

    if (this.$store.state.offModel) {
      succ(mockArea);
    } else {
      $api.publication.findAllresearchAreasClient().then(succ);
    }
  }
}
</script>

<style lang="scss">
.comp-publication-wrapper {
  padding: 0 30px;
  margin-bottom: 15px;
  .container {
    text-align: left;
    width: 1200px;
    margin: auto;
  }
  .pub-area {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .area-wrapper {
    width: 100%;
    padding-bottom: 15px;
    background: white;
    h3 {
      background: #113f6c;
      color: white;
      padding: 10px 20px;
      margin-top: 0;
    }
  }
  .area-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 0 20px;
    .area-instance {
      text-align: center;
      box-sizing: border-box;
      width: 50%;
      text-align: left;
      background: white;
      padding: 10px 20px;
      position: relative;
      border: 1px solid gainsboro;
      border-top: none;
      &:nth-child(2n){
        border-left: none;
      }
      &:nth-child(1),&:nth-child(2){
        border-top: 1px solid gainsboro;
      }
    }
    .title{
      font-weight: bold;
    }
    .content {
      font-size: 15px;
      margin: 15px 0;
    }
    .img {
      position: absolute;
      bottom: 10px;
      left: calc(50% - 40px);
      img {
        height: 80px;
      }
    }
  }
  .pub-container {
    width: 100%;
    margin-top: 15px;
    background: white;
    h3 {
      padding: 10px 20px;
      margin-top: 0px;
      background: #f5ae54;
      color: white;
      span {
        font-size: 14px;
        color: rgb(58, 57, 57);
      }
      .read-more {
        float: right;
        cursor: pointer;
        &:hover {
          color: #113f6c;
        }
      }
    }
    .pub-instance {
      padding: 15px 20px;
      border-bottom: 1px solid gainsboro;
      margin-bottom: 1px;
      background: white;
      &:last-child {
        border: none;
      }
      .content{
        display: inline;
        span{
          font-weight: bold;
          color: #113f6c;
          font-style: italic;
        }
        strong{
          color: #7030A0;
          font-style: italic;
        }
      }
      .number{
        font-weight: bold;
        font-style: italic;
        margin-right: 5px;
      }
    }
  }
  .photos-container {
    margin-top: 50px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    .img-instance {
      width: 31%;
      margin-bottom: 15px;
      img {
        width: 100%;
      }
      box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.1);
      &:nth-child(2),
      &:nth-child(3),
      &:nth-child(4) {
        margin-top: 20px;
      }
    }
    .el-divider__text {
      background: #ececec;
      font-size: 20px;
      font-weight: bold;
      color: #113f6c;
    }
  }
}
// @media screen and (max-width: 1200px) {
//   .comp-publication-wrapper {
//     .area-wrapper {
//       width: 45%;
//     }
//     .pub-container {
//       width: 54%;
//     }
//   }
// }
// @media screen and (max-width: 700px) {
//   .comp-publication-wrapper {
//     padding: 30px 10px;
//     .pub-area {
//       flex-wrap: wrap;
//     }
//     .area-wrapper,
//     .pub-container {
//       width: 100%;
//     }
//     .pub-container {
//       margin-top: 15px;
//     }
//     .photos-container {
//       .img-instance {
//         width: 47%;
//       }
//     }
//   }
// }
</style>